package io.gitee.tziye.core.kv.model;

import io.gitee.tziye.RenaiClient;
import io.gitee.tziye.core.kv.PriorityQOperator;
import io.gitee.tziye.core.kv.RenaiKey;
import io.gitee.tziye.core.kv.RenaiValue;
import io.gitee.tziye.enums.KvType;
import io.vavr.Tuple2;

import java.util.List;

public class RenaiPriorityQ<T> extends RenaiKVCollection<T> {

    private final PriorityQOperator priorityQOperator;

    public RenaiPriorityQ(RenaiClient renaiClient, String key, Class<T> clazz, Integer expireSeconds) {
        super(renaiClient, key, clazz, KvType.PriorityQ);
        priorityQOperator = renaiClient.priorityQ();
        priorityQOperator.saveKey(key, expireSeconds);
    }

    @Override
    public RenaiKey key() {
        return priorityQOperator.key(key);
    }

    @Override
    public void expire(int expireSeconds) {
        priorityQOperator.expire(key, expireSeconds);
    }

    @Override
    public boolean exists() {
        return priorityQOperator.exists(key);
    }

    @Override
    public boolean delete() {
        return priorityQOperator.delete(key);
    }

    @Override
    public List<RenaiValue> values(String key) {
        return priorityQOperator.values(key);
    }

    @Override
    public int size() {
        return priorityQOperator.size(key);
    }

    @Override
    public boolean contains(T value) {
        return priorityQOperator.contains(key, value);
    }

    @Override
    public int clear() {
        return priorityQOperator.clear(key);
    }

    @Override
    public boolean remove(T value) {
        return priorityQOperator.remove(key, value);
    }

    @Override
    public int removeValues(List<T> values) {
        return priorityQOperator.removeValues(key, values);
    }

    public List<Tuple2<T, Long>> members() {
        return priorityQOperator.members(key, clazz);
    }

    public void add(T value, long score) {
        priorityQOperator.add(key, value, score);
    }

    public void add(List<Tuple2<T, Long>> list) {
        priorityQOperator.add(key, list);
    }

    public void addIfAbsent(T value, long score) {
        priorityQOperator.addIfAbsent(key, value, score);
    }

    public void addIfAbsent(List<Tuple2<T, Long>> list) {
        priorityQOperator.addIfAbsent(key, list);
    }

    public void addCover(T value, long score) {
        priorityQOperator.addCover(key, value, score);
    }

    public void addCover(List<Tuple2<T, Long>> list) {
        priorityQOperator.addCover(key, list);
    }

    public List<Tuple2<T, Long>> get(int start, int count) {
        return priorityQOperator.get(key, start, count, clazz);
    }

    public List<Tuple2<T, Long>> revGet(int start, int count) {
        return priorityQOperator.revGet(key, start, count, clazz);
    }

    public List<Tuple2<T, Long>> getByScore(long start, long end) {
        return priorityQOperator.getByScore(key, start, end, clazz);
    }

    public List<Tuple2<T, Long>> pop(int start, int count) {
        return priorityQOperator.pop(key, start, count, clazz);
    }

    public List<Tuple2<T, Long>> revPop(int start, int count) {
        return priorityQOperator.revPop(key, start, count, clazz);
    }

    public List<Tuple2<T, Long>> popByScore(long start, long end) {
        return priorityQOperator.popByScore(key, start, end, clazz);
    }

    public int delete(int start, int count) {
        return priorityQOperator.delete(key, start, count);
    }

    public int revDelete(int start, int count) {
        return priorityQOperator.revDelete(key, start, count);
    }

    public int deleteByScore(long start, long end) {
        return priorityQOperator.deleteByScore(key, start, end);
    }

    public List<Long> score(T value) {
        return priorityQOperator.score(key, value);
    }

    public Long minScore(T value) {
        return priorityQOperator.minScore(key, value);
    }

    public Long maxScore(T value) {
        return priorityQOperator.maxScore(key, value);
    }

    public List<Integer> rank(T value) {
        return priorityQOperator.rank(key, value);
    }

    public Integer highestRank(T value) {
        return priorityQOperator.highestRank(key, value);
    }

    public Integer lowestRank(T value) {
        return priorityQOperator.lowestRank(key, value);
    }

    public List<Integer> revRank(T value) {
        return priorityQOperator.revRank(key, value);
    }

    public Integer revHighestRank(T value) {
        return priorityQOperator.revHighestRank(key, value);
    }

    public Integer revLowestRank(T value) {
        return priorityQOperator.revLowestRank(key, value);
    }

    public List<Long> incr(T value, long score) {
        return priorityQOperator.incr(key, value, score);
    }

}
